           package com.java.diagnostics.visualizer.impl.sources;
           
           import java.io.BufferedInputStream;
           import java.io.IOException;
           import java.io.InputStream;
           
           public class PositionAwareBufferedInputStream extends BufferedInputStream
           {
             private static final SourcePreferenceHelper SOURCE_PREFERENCE_HELPER = new SourcePreferenceHelper();
             private int maxAllowedReadBytes;
             private int position = 0;
           
             public PositionAwareBufferedInputStream(InputStream stream) {
               super(stream);
            // deleted by wenguang.huang 
              // this.maxAllowedReadBytes = SOURCE_PREFERENCE_HELPER.getBufferSize();
            this.maxAllowedReadBytes =2048;
             }
           
             public synchronized int read() throws IOException
             {
               int read = super.read();
               this.position += read;
               return read;
             }
           
             public synchronized int read(byte[] b, int off, int len)
               throws IOException
             {
               int read = super.read(b, off, this.maxAllowedReadBytes);
               this.position += read;
               return read;
             }
           
             public synchronized void reset() throws IOException {
               this.position = 0;
               super.reset();
             }
           
             public synchronized long skip(long n) throws IOException {
               long skipped = super.skip(n);
               this.position = ((int)(this.position + skipped));
               return skipped;
             }
           
             public int getPosition() {
               return this.position;
             }
           }

